import axios from "axios";

//
const prefix = '/nifi-api'

// nifi-api/flow/process-groups/root?uiOnly=true
export const getRoot = () => {
  return axios.get(prefix + '/flow/process-groups/root?uiOnly=true');
}

// /nifi-api/flow/process-groups/0d475669-018a-1000-b898-4be99f56952c/status/history
// nifi-api/flow/processors/0d475669-018a-1000-b898-4be99f56952c/status/history
// /nifi-api/flow/process-groups/0d475669-018a-1000-b898-4be99f56952c?uiOnly=true
export const getInfo = (item:any) => {
  if(item.inputPortCount == undefined){
    console.warn(' ==== getInfo ==== ','节点类型不是 group ')
  }
  const id = item.id;
  return axios.get(prefix +  `/flow/process-groups/${id}?uiOnly=true`);
}

export const getHistory = (item:any) => {
  const id = item.id;
  const type = item.inputPortCount == undefined ? 'processors' : 'process-groups'
  return axios.get(prefix + `/flow/${type}/${id}/status/history`)
}

// /nifi-api/process-groups/subprocess {"subprocess":"sefafeaefwefa","catalog":"test12314123"}
export const getSlideList = () => {
  return axios.get(prefix + '/process-groups/subprocess')
}

export const addSliderFlow = (data:any = {}) => {
  return axios.post(prefix + '/process-groups/subprocess',data)
}
// {"id":"69a82bf2-018a-1000-ec9e-6c3488775d08"}
export const delSliderFlow = (id:string) => {
  return axios.delete(prefix + '/process-groups/subprocess',{data:{id}})
}